﻿using System;

namespace eStock.SQL
{
    [Serializable]
    public class SQLNotConnectedException : Exception
    {
        public string ErrorMessage{get{return base.Message;}}

        public SQLNotConnectedException(string errorMessage = "No SQL connection found. Run Connect() first.")
            : base(errorMessage) { }

        public SQLNotConnectedException(string errorMessage, Exception innerEx)
            : base(errorMessage, innerEx) { }
    }

    [Serializable]
    public class SQLError : Exception
    {
        private string PMsg { get; set; }

        public string ErrorMessage
        {
            get
            {
                if (string.IsNullOrEmpty(PMsg))
                    return base.Message;
                return PMsg;
            }
            set { PMsg = value; }
        }

        public SQLError(string errorMessage = "Error while perfoming SQL command.")
            : base(errorMessage) { }

        public SQLError(Exception innerEx, string errorMessage = "Error while perfoming SQL command")
            : base(errorMessage, innerEx)
        {
            PMsg = errorMessage + ":\n\n" + innerEx.Message;
        }
    }
}
